﻿#include<iostream>
using namespace std;
class A {
public:
    A();
    ~A();
    static A* getInstance();
    void print();
    A(const A& other);
    A& operator=(const A& other);
private:
    static A* InstanceA;
};
A::A() {
}

A::~A() {
    if (InstanceA != nullptr) {
        delete InstanceA;
    }
}

A* A::getInstance() {
    if (InstanceA == nullptr) {
        InstanceA = new A();
    }
    return InstanceA;
}

void A::print() {
    std::cout << InstanceA;
}

A* A::InstanceA = nullptr;

int main() {
    A* Instance1 = A::getInstance();
    A* Instance2 = A::getInstance();

    Instance1->print();
    cout << endl;
    Instance2->print();
}